package com.raja.servingStation.common.constant;


import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;
import java.util.List;

/**
 * mysql分页类
 * Created by liuyanjun
 * on 2017/8/31/031.
 */
public class MysqlPageVo<T> {
    //返回数据集合用
    private Integer total;		// 总行数xx
    private List<?> data = new ArrayList<>();   	// 数据集合

    //分页用
    private Integer pageSize;		// 页面显示行数
    @JSONField(serialize=false)
    private Integer offset;		// 分页开始行
    @JSONField(serialize=false)
    private boolean isPage = false;	// 是否分页
    private Integer currPage;

    /**
     * 所有的导出：继承该类的类，如果声明构造函数需要调用super();
     */
    public MysqlPageVo(){
        setPageSize(10, 1);
        this.isPage = false;
    }

    //不分页，只获取部分
    public void setPageSize(int size){
        setPageSize(size, 1);
        this.isPage = false;
    }

    public void setPageSize(Integer pageSize, Integer currPage) {
        this.pageSize = pageSize;
        this.offset = (Integer.valueOf(currPage) - 1) * pageSize;
        this.isPage = true;
        this.currPage = currPage;
    }

    public List<?> getData() {
        return data;
    }

    public void setData(List<?> data) {
        this.data = data;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public Integer getOffset() {
        return offset;
    }
    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public void setIsPage(boolean isPage) {
        this.isPage = isPage;
    }

    public boolean getIsPage(){
        return isPage;
    }

    public Integer getCurrPage() {
        return currPage;
    }

    public void setCurrPage(Integer currPage) {
        this.currPage = currPage;
    }
}
